package com.example.news;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

@Route(path = "/news/fragment")
public class NewsFragment extends Fragment {
    private View rootView;
    private TextView textView;
    @Autowired
    public String news;


    public static NewsFragment newInstance(String s){
        NewsFragment myFragment = new NewsFragment();
        Bundle bundle = new Bundle();
        bundle.putString("title",s);
        myFragment.setArguments(bundle);
        return myFragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.ac_news, container, false);
        ARouter.getInstance().inject(this);
        initView();
        return rootView;
    }

    private void initView() {
        textView = rootView.findViewById(R.id.tv_title);
        textView.setText(news);
    }

    public void setTitle(String title) {
        this.news = title;
    }
}
